
#include"vtorus.h"
#include<stdlib.h>
#include<math.h>
#include<stdio.h>

#define _R 10
#define _r 3

void VTorus::FillCoordAndBox ()
{
  //printf("VTorus %d %d\n", n_vertices,n_triangles);
  float * vertices = GetVertArray();
  float step = 2*_PI/(n-1);
  int v_id=0;
  for(int u=0;u<n;u++){
    for(int v=0;v<n;v++){
      vertices[v_id*3]   = (_R + _r*cos(v*step))*cos(u*step);
      vertices[v_id*3+1] = (_R + _r*cos(v*step))*sin(u*step);
      vertices[v_id*3+2] = _r*sin(v*step);
      v_id++;
    }
  }
  CalcNormals();
  xmax= _R;
  ymax= _R;
  zmax= _R;
  xmin=-_R;
  ymin=-_R;
  zmin=-_R;
}

